package com.blog4j.system.api;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.blog4j.common.annotation.OperationLog;
import com.blog4j.common.enums.ModuleTypeEnum;
import com.blog4j.common.model.Result;
import com.blog4j.requestRate.annotation.RequestRate;
import com.blog4j.system.service.ChartService;
import com.blog4j.system.vo.resp.ChartInfoRespVo;
import com.blog4j.system.vo.resp.ContributeDateRespVo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 98k灬
 * @version v1.0.0
 * @Description : 功能描述
 * @Create on : 2024/8/7 12:24
 **/
@RestController
@RequestMapping("/api/chart")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class ApiChartController {
    private final ChartService chartService;

    /**
     * 统计首页大屏的信息
     *
     * @return 首页大屏的信息
     */
    @RequestRate
    @OperationLog(module= ModuleTypeEnum.SYSTEM, description = "统计首页大屏的信息")
    @SaCheckLogin
    @GetMapping("/chartInfo")
    public Result chartInfo() {
        ChartInfoRespVo respVo = chartService.chartInfo();
        return Result.ok(respVo);
    }

    /**
     * 获取一年内文章贡献度
     *
     * @return 一年内文章贡献度
     */
    @RequestRate
    @OperationLog(module= ModuleTypeEnum.SYSTEM, description = "获取一年内文章贡献度")
    @SaCheckLogin
    @GetMapping("/getContributeData")
    public Result getContributeData() {
        ContributeDateRespVo respVo = chartService.getContributeData();
        return Result.ok(respVo);
    }
}
